<?php

function isphone($s) {
    if (preg_match('/^\d*$/', $s) == 0) {
        return false;
    }
    if (preg_match('/^0\d{10,11}$/', $s) != 0) {
        return true;
    }
    if (preg_match('/^1[358]\d{9}$/', $s) != 0) {
        return true;
    }

    return false;
}

function msghc2querycode($hc) {
    $result = ''.$hc;
    if ($hc >= 0) {
        $result = 'ZA' . $result;
    } else {
        $result = str_replace('-', 'ZB', $result);
    }
    
    return $result;
}

function querycode2msghc($qc) {
    $result = str_replace('ZA', '', strtoupper($qc));
    $result = str_replace('ZB', '-', $result);
    return (int)$result;
}

function generateOrderid() {
    $result = 'ZP';
    $result .= time();
    $result .= substr(microtime(), 2, 6);
    return $result;

}

function generateTimestamp() {
    $result = '';
    $result .= microtime();
    $result .= rand(10000, 99999);
    $result = preg_replace('/[\. ]/', '', $result);
    return $result;
}

function strDecHash($s) {
    return hexdec(hash('crc32b', $s));
}


